package com.ioidea.ble.proto

import com.ioidea.base.util.MyLogger
import com.ioidea.base.util.Symbol

/**
 *
 * 首次获取白名单
 * request:   @@12233445:WHSGET\r\n
 * response:  ##12233445:WHMULT:000 003 003 A172508548F2 A172497113F2 A172500209F2
 *
 * 下一次是
 * request:   @@12233445:WHMULT\r\n
 * response:  ##12233445:WHMULT:000 003 003 A172508548F2 A172497113F2 A172500209F2
 */
class GetGroupsProtoBase(override var requestCommand: String="GETSTAGROUPS",
                         override var responseCommand: String="STA_GROUP") : ProtoBase() {




    fun parseGroupDeviceResponse( wholeData: String) :GroupChildDevice? {
        //去头尾
        val data = removeHeadTail(wholeData)
        MyLogger.hLog().e("data:$data")
        //后面可以校验数据长度是否正确 暂时让数据有问题的奔溃 发现问题
        val dataArray= data.split(Symbol.SPACE)
        if (dataArray.size==2){
            val childDevSn=dataArray[0]
            val groupId=dataArray[1].toInt()
            return GroupChildDevice(childDevSn,groupId)
        }
        return null

    }
}

data class GroupChildDevice(var childDevSn:String,var groupId:Int)



